package cn.javass.dp.iterator.example5;

import java.util.Iterator;
import java.util.function.Consumer;

public class ArrayIteratorImpl implements Iterator {

    private SalaryManager salaryManager;

    private int index = 0;

    public ArrayIteratorImpl(SalaryManager salaryManager) {
        this.salaryManager = salaryManager;
    }


    @Override
    public boolean hasNext() {
        if (index < salaryManager.size()) {
            return true;
        }
        return false;
    }

    @Override
    public Object next() {
        Object obj = null;
        if (index < salaryManager.size()) {
            obj = salaryManager.get(index);
            index++;
        }
        return obj;
    }

    @Override
    public void remove() {

    }

    @Override
    public void forEachRemaining(Consumer action) {
    }
}
